//
//  SdDrapView.swift
//  onemeetingmac
//
//  Created by 张衡 on 2020/6/23.
//  Copyright © 2020 onemeeting. All rights reserved.
//

import Foundation

class SdDrapView: MSView {
    override init(frame frameRect: NSRect) {
        super.init(frame: frameRect)
        self.setupUI()
        self.loadData()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    func loadData()  {
        self.status = { state in
            self.container.wantsLayer = true
            switch state {
            case .normal:
                self.container.layer?.backgroundColor = color_gray(0).cgColor
            case .highlight,.hover,.selected:
                self.container.layer?.backgroundColor = color_gray(160).cgColor
            }
        }
    }
    
    func setupUI() {
        self.addSubview(container)
        container.snp.makeConstraints { (make) in
            make.centerX.equalToSuperview()
            make.centerY.equalToSuperview()
            make.width.equalTo(10)
            make.height.equalToSuperview()
        }
        
        container.addSubview(icon)
        icon.snp.makeConstraints { (make) in
            make.center.equalToSuperview()
            make.width.equalTo(10)
            make.height.equalTo(30)
        }
    }
    
    lazy var container: NSView = {
        let view = NSView()
        view.wantsLayer = true
        view.layer?.backgroundColor = NSColor.clear.cgColor
        return view
    }()
    
    lazy var icon: NSImageView = {
        let imageV = NSImageView.init(image: NSImage.image(name:"icon_drapBtn_sd")!)
        return imageV
    }()
    
    
}
